package com.rohoo.user.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.rohoo.user.bo.LoginUser;
import com.rohoo.user.dao.SloginDAO;
import com.rohoo.user.service.SloginService;

public class SloginServiceImpl implements SloginService{
	
	private SloginDAO sloginDAO;
	private Log log = LogFactory.getLog(getClass());
	
	public String getPwd(String loginname) throws Exception {
		String result;
		try {
			result = sloginDAO.getPwd(loginname);
		} catch (Exception ex) {
			if(log.isErrorEnabled())
				log.error("getPwd Error!", ex);
			throw new Exception("getPwd Error!", ex);
		}
		return result;
	}
	
	public int getUserId(String loginname) throws Exception {
		int result;
		try {
			result = sloginDAO.getUserId(loginname);
		} catch (Exception ex) {
			if(log.isErrorEnabled())
				log.error("getUserId Error!", ex);
			throw new Exception("getUserId Error!", ex);
		}
		return result;
	}
	
	public LoginUser getLoginUser(int userid) throws Exception {
		try{
			LoginUser student = sloginDAO.getLoginUser(userid);
			return student;
		}catch (Exception e) {
			throw new Exception("SloginServiceImpl getLoginUser Error!", e);
		}
	}
	
	public SloginDAO getSloginDAO() {
		return sloginDAO;
	}
	public void setSloginDAO(SloginDAO sloginDAO) {
		this.sloginDAO = sloginDAO;
	}
}
